package com.mq.dialogdemo.timepicker;

import android.app.TimePickerDialog;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.widget.TimePicker;

import com.mq.dialogdemo.R;
import com.mq.dialogdemo.datepicker.DatePickerActivity;

import java.util.Calendar;

public class TimePickerActivity extends AppCompatActivity
        implements TimePickerDialog.OnTimeSetListener {
    private static final String TAG = TimePickerDialog.class.getSimpleName();

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_time_picker);

        Calendar calendar = Calendar.getInstance();

        int hour = calendar.get(Calendar.HOUR_OF_DAY);
        int minute = calendar.get(Calendar.MINUTE);

        TimePickerDialog timePickerDialog = new TimePickerDialog(this, this, hour, minute, true);

        timePickerDialog.show();
    }

    @Override
    public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
        Log.e(TAG, "onTimeSet: h = " + hourOfDay + " m = " + minute);
    }
}
